import service from "@/api/index.js";

const userApi = {
    // 获得全部用户信息
    getALl(condition,pageNum, pageSize) {
        condition.pageNum = pageNum
        condition.pageSize = pageSize
        return service.get('/user/list',{params:condition})
    },
//     通过id查询用户信息
    getById(id) {
        return service.get(`/user/${id}`)
    },
//     更新用户信息
    updateInfo(user) {
        return service.put('/user',user)
    },
//     获取用户登录验证码
    captcha() {
        return service.get("/user/captcha")
    },
//     用户登录
    login(username,password,key,captchaInput) {
        return service.post('/user/login',{username, password, key, captchaInput},{
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
//     用户注册
    reg(username,password,key,captchaInput) {
        return service.post('/user/registered',{username, password, key, captchaInput},{
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
//     获取登录用户信息
    getInfo() {
        return service.get('/user/info')
    },
//     修改密码
    changePwd(password,newPassword,newPasswordAgain) {
        return service.post('/user/change/pwd',{password,newPassword,newPasswordAgain},{
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
//     验证支付密码
    verifyPayPassword(payPassword) {
        return service.post('/user/verifyPayPassword',{payPassword},{
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
//     修改支付密码
    changePayPassword(payPassword, newPayPassword, payPasswordAgain) {
        return service.post('/user/changePayPassword',{payPassword, newPayPassword, payPasswordAgain},{
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    },
//     余额充值
    rechargeBalance(money) {
        return service.post('/user/rechargeBalance',{money},{
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
    }
}

export default userApi